package leetcode;


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.LinkedHashSet;

/**
 * create by duanx 2022/2/7
 *
 * @classname: Test3
 * @author: duanx
 * @date: 2022/2/7 9:22
 **/
public class Test13 {

    public static void main(String[] args){
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String str;
        try{
            while(!(str = reader.readLine()).isEmpty()){
                String s1 = "abcdefghijklmnopqrstuvwxyz";
                String s2 = "";
                String word = reader.readLine();

                LinkedHashSet<Character> set = new LinkedHashSet<>();
                for (int i=0;i<str.length();i++){
                    set.add(str.charAt(i));
                }
                StringBuilder key = new StringBuilder();
                for (char c:set){
                    key.append(c);
                }
                StringBuilder builder = new StringBuilder();
                for (int i=0;i<s1.length();i++){
                    boolean flag = true;
                    for (int j=0;j<key.length();j++){
                        if (s1.charAt(i)==key.charAt(j)){
                            flag = false;
                        }
                    }
                    if (flag){
                        builder.append(s1.charAt(i));
                    }
                }
                s2 = String.valueOf(key.append(builder));
                StringBuilder newWord = new StringBuilder();
                for (int i =0;i<word.length();i++){
                    for (int j =0;j<s1.length();j++){
                        if (word.charAt(i)==s1.charAt(j)){
                            newWord.append(s2.charAt(j));
                        }
                    }
                }
                System.out.println(newWord);

            }
        }catch(Exception e){
            System.out.printf(e.toString());
        }
    }
}
